

require('../css/commCss/basic.css')
require('../css/commCss/normalize.css')
require('../css/commCss/property.css')
require('../css/commCss/reset.css')


require('../css/sign in.less')

//引入axios
const axios = require('axios')

//获取元素
const signText=document.querySelector('.sign-text')//登录账号
const signPassword=document.querySelector('.sign-password')//登录密码
const signBtn=document.querySelector('.sign-btn')//登录按钮
const signMsg=document.querySelector('.signMsg')

//点击signBtn,验证登录合法性

signBtn.addEventListener('click',function(){

    // console.log(123);

    //获取输入信息
    const signTextVal=signText.value//登录账号
    const signPasswordVal=signPassword.value//登录密码

    //判断
    if(!/^1[3-9][0-9]{9}$/.test(signTextVal)){
        signMsg.textContent='手机号错误'
        return;

    }else if(!/^[a-zA-Z]\w{5,11}$/.test(signPasswordVal)){
        signMsg.textContent='密码错误'
        return

    }else{
        signMsg.textContent=''
        signText.value=signPassword.value=''

        axios.post('http://139.9.177.51:8099/users/login',{
            account:signTextVal,
            password:signPasswordVal
        }).then(function(res){
            //判断
            if(res.data.status===0){
                //成功
                //先弹出一个轻提示

                //跳转首页
                location.href='./home.html'
            }else{
                //失败
                //先弹出一个轻提示
            }
        })
    }

})